import styles from "./setting.module.scss";
import React, { Component } from "react";
import { withRouter,Redirect } from "react-router-dom";
import { connect } from "react-redux";
import {
  logoutAction,
} from "../../store/actionCreator/loginAction";
class SettingPage extends Component {
  render() {
    if (!this.props.isLogin) {
      return <Redirect to="/user"></Redirect>;
    } else {
    return (
      <div>
        <div className={styles.setting}>
          <div className={styles.settingLeft}>
            <svg
              className={styles.icon}
              aria-hidden="true"
              onClick={() => {
                this.props.history.push("/user");
              }}
            >
              <use href="#icon-zuojiantou"></use>
            </svg>
          </div>
          <div className={styles.topNavCenter} style={{ paddingRight: "43%" }}>
            设置
          </div>
        </div>
        <div className={styles.list}>
          <p>
            <span>账号安全</span>
            <b>
            <em>开启小额免费支付</em>
              <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg>
            </b>
          </p>
          <p>
            <span>通用</span>
            <b> <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg></b>
          </p>
          <p>
            <span>欢迎评分</span>
            <b> <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg></b>
          </p>
          <p>
            <span>关于吃了么</span>
            <b> <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg></b>
          </p>
          <p>
            <span>隐私</span>
            <b> <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg></b>
          </p>
          <p>
            <span>意见反馈</span>
            <b> <svg className={styles.icon} aria-hidden="true">
                <use href="#icon-you-copy"></use>
              </svg></b>
          </p>
        </div>
        <div className={styles.logout}
        onClick={
          this.props.logout.bind(this)
        }>退出当前帐号</div>
      </div>
    );
  }
}
}
const mapStateToPorps = (state) => {
  return {
    isLogin: state.loginReducer.isLogin
  };
};
const mapDispatchToProps = (dispatch) => {
  return {
    logout(e) {
      dispatch(logoutAction());
    },
  };
};
export default withRouter(connect(mapStateToPorps, mapDispatchToProps)(SettingPage));
